<?php
/**
 * 审批管理——我发起的审批
 * User: zhao shou qiang
 * Date: 2018/1/12 0012
 * Time: 16:44
 */

use yii\widgets\LinkPager;
use yii\helpers\Url;
use yii\helpers\Html;
use frontend\assets\AppAsset;

$this->title = '审批管理——我发起的审批';

$this->registerCssFile('@web/css/my-approve.css', ['depends' => ['backend\assets\AppAsset'], 'position' => $this::POS_HEAD]);
$this->registerCssFile('@web/css/paging.css', ['depends' => ['backend\assets\AppAsset'], 'position' => $this::POS_HEAD]);
$this->registerCss('
    .un-can-click{cursor: default!important;color: #888888!important;}
');

AppAsset::addScript($this, '@web/js/my-approve.js');
AppAsset::addScript($this, '@web/js/myApplication.js');

?>
<style type="text/css">
    #subForm {
        display: inline-block;
        margin-left: -7px;
        width: 70px;
        height: 40px;

    }

    #subForm img {
        display: inline-block;
        width: 70px;
        height: 40px;
        border-radius: 0px 2px 2px 0px;
    }

    .approval {
        cursor: pointer !important;
    }

    .active {
        font-weight: bolder;
    }

    .mytable tr:nth-child(2) td,
    .mytable tr:nth-child(3) td {
        font-size: 14px !important;
        font-weight: 100 !important;
    }

    .mytable tr td:nth-child(even) span {
        font-size: 14px !important;
        font-weight: 100 !important;
    }
    
    .myBagSeachBox .container {
    	margin-top: 0px;
    }
    .wrap > .container-fluid > .container {
        width: 100%!important;
    }
    .navbar{
        border: none;
    }
</style>
<!--一键置 顶-->
<a href="#" class="clicktop" title="返回顶部">
    <!--<img src="image/common/clickTop.png" alt=""  />-->
</a>
<!--一键置 顶结束-->


<!--资产包详情搜索部分开始-->
<div class="myBagSeachBox">
    <div class="container">
        <div class="top">
            <a href="/">办公大厅</a>
            <a href="javascript:;"> > 审批管理</a>
            <a href="javascript:;" class="pagedetails"> > 我发起的审批</a>
        </div>
        <ul id="myTab" class="nav nav-tabs">
            <?php
            if (!empty($is_show)) {
                ?>
                <li>
                    <a href="/audit-management">
                        立项审批<!--（<span><?php /*echo $counts['approvalCounts']; */ ?></span>）-->
                    </a>
                </li>
                <?php
            }
            ?>
            <li id="">
                <a href="/audit-management/access?shenPiGroup=5&result=&accessKey=" >
                    访问审批<!--（<span><?php /*echo $counts['visitCounts']; */ ?></span>）-->
                </a>
            </li>
            <li class="active" id="myAudit">
                <a href="#myAttentionPackage" data-toggle="tab">
                    我发起的审批<!--（<span><?php /*echo $counts['allCounts']; */ ?></span>）-->
                </a>
            </li>
        </ul>

        <div id="myTabContent" class="tab-content">
            <div class="tab-pane fade in active" id="myPortfolioPackage">
                <input type="hidden" id="my_application_page_url"
                       value="<?php echo Url::toRoute('audit-management/ajax-application', true); ?>">

                <input type="hidden" id="access_application_url"
                       value="<?php echo Url::toRoute('audit-management/access', true); ?>">

                <input type="hidden" id="application_url"
                       value="<?php echo Url::toRoute('audit-management/index', true); ?>">

                <form name="search_audit" action="<?php echo Url::toRoute('audit-management/ajax-application'); ?>"
                      method="get">

                    <input type="hidden" name="page" id="current_page" value="1">

                    <input type="hidden" name="workflow_status" id="my_application_state" value="0">

                    <input type="hidden" name="result" id="my_application_result" value="0">

                    <input type="text" name="search" class="search" list='searchLi' style="margin-bottom: 20px;"
                           placeholder="输入资产包关键字/申请人快速查询"/>
                    <a href="javascript:void(0)" id="subForm">
                        <img src="/image/officeHall/searchs.png" class="" style="margin-top: -1px;">
                    </a>
                    <datalist id='searchLi'>
                        <option><?php echo Html::encode($realname); ?></option>
                    </datalist>
                </form>
            </div>
        </div>
    </div>
</div>

<!--资产包详情列表结开始-->
<div class="myBagListBox">
    <div class="container">
        <div class="row ">
            <div class="top">
                <img src="/image/myAssetBag/wsxx.png" class="pull-left"/>
                <p>我发起的审批</p>
            </div>
            <ul id="myTabTwo" class="nav nav-tabs">
                <li class="active">
                    <a href="#quanBu" data-toggle="tab" onclick="setStatus(0,0,0)">
                        全部（<span><?php echo $counts['allCounts']; ?></span>）
                    </a>
                </li>
                <li>
                    <a href="#tongGuo" data-toggle="tab" onclick="setStatus(2,2,1)">
                        已通过（<span><?php echo $counts['passCounts']; ?></span>）
                    </a>
                </li>
                <li>
                    <a href="#weiTongGuo" data-toggle="tab" onclick="setStatus(3,2,2)">
                        未通过（<span><?php echo $counts['refuseCounts']; ?></span>）
                    </a>
                </li>
                <li>
                    <a href="#shenPiZhong" data-toggle="tab" onclick="setStatus(1,1,3)">
                        审批中（<span><?php echo $counts['unauditedCounts']; ?></span>）
                    </a>
                </li>
            </ul>

            <div id="myTabContent" class="tab-content">
                <div class="tab-pane fade in active" id="quanBu">
                    <form class="tabForm" action="">
                        <?php
                        $html = '';
                        if (!empty($data) && is_array($data)) {
                            foreach ($data as $key => $value) {
                                if ($value['is_package'] == 1) {
                                    $show_title = '资产包名称';
                                } else {
                                    $show_title = '项目名称';
                                }

                                $html .= '<table border="" cellspacing="" cellpadding="" class="mytable">
                                    <tr>
                                        <td colspan="8">' . $value['type'] . '</td>
                                    </tr>
                                    <tr>
                                        <td  style="width: 100px;">' . $show_title . ':</td>
                                        <td>';

                                if($value['is_package'] == 1) {
                                    $filterPackage = \backend\controllers\DtActionFilter::checkPackage("package_view", $value['package_id']);
                                    if ($filterPackage){
                                        $pacUrl = Url::toRoute(['package/detail-info', 'packageid' => $value['package_id']]);
                                        $a = '<a href="javascript:void(0);" onclick="javascript:window.open(' . "'" . $pacUrl . "'" . ')">';
                                    }else{
                                        $a = '<a href="javascript:layer.msg(\'您没有访问权限\')">';
                                    }
                                    $html .= $a . '<span class="txt-cut" title="" style="color:#2096f1;cursor:pointer;">' . $value['application_tilte'] . '</span></a>';
                                } elseif($value['is_package'] == 2) {
                                    $packageModel = \common\models\Project::findOne((int)$value['package_id']);
                                    $filterProject = \backend\controllers\DtActionFilter::checkProject("project_view",$value['package_id']);
                                    if ($filterProject ){
                                        $proUrl = Url::toRoute(['project/getinfodata', 'package_id' => $packageModel['package_id'], 'project_id'=>$value['package_id']]);
                                        $a = '<a href="javascript:void(0);" onclick="javascript:window.open(' . "'" . $proUrl . "'" . ')">';
                                    }else{
                                        $a = '<a href="javascript:layer.msg(\'您没有访问权限\')">';
                                    }
                                    $html .= $a . '<span class="txt-cut" title="" style="color:#2096f1;cursor:pointer;">' . $value['application_tilte'] . '</span></a>';
                                }

                                $html .= '</td>
                                        <td>
                                            申请时间:
                                        </td>
                                        <td>
                                            <span class="txt-cut" title="">' . $value['applied_at'] . '</span>
                                        </td>
                                        <td>
                                            审批结果:
                                        </td>
                                        <td>
                                            <span class="txt-cut" title="">' . $value['result'] . '</span>
                                        </td>
                                        <td>
                                            审批人:
                                        </td>
                                        <td>
                                            <span title="' . $value['user'] . '">' . $value['user'] . '</span>
                                        </td>
                                    </tr>
                                    <tr>
                                        <td>申请理由:</td>
                                        <td colspan="3">
                                            <div style="word-break: break-all; word-wrap: break-word; width: 400px;">
                                                ' . $value['reason'] . '
                                            </div>
                                        </td>     
                                        <td>审批意见:</td>
                                        <td colspan="3">
                                            <div style="word-break: break-all; word-wrap: break-word; width: 400px;">
                                                ' . $value['note'] . '
                                            </div>
                                        </td> 
                                    </tr>
                                    <tr>
                                        <td>
        
                                        </td>
                                    </tr>
                                </table>
                                ';
                            }
                        }
                        echo $html;
                        ?>
                    </form>
                </div>
            </div>
        </div>

        <div class="pagingBox" style="padding-left: 222px;">
            <div id="page_list" class="pull-left">
                <?php echo $pages; ?>
            </div>
            <!--<div class="pull-left" style="margin: 23px 12px">
                    <span class="pageTotal pull-left">
                        <span class="pageT"></span> 每页
                        <a id="list">
                            <span class="number">10</span>
                            <ul class="pageTotalBox">
                                <li class="pageActive">10</li>
                                <li>20</li>
                                <li>30</li>
                                <li>40</li>
                                <li>50</li>
                            </ul>
                        </a>
                        <b class="caret"> </b>行
                    </span>
                共<span class="totalSize"><?php echo $counts['allCounts']; ?> </span>条记录
            </div>-->
        </div>
    </div>
</div>